
local function is_in_list(checkme, list)
    for _, listed in ipairs(list) do
        -- need these parameters in minetest environment
         if string.find(checkme, listed, 1, true) ~= nil then
            return true;
        end;
    end;
    return false;
end

local function sort_items2()
    local grinder = "black";
    local furnace = "green";
    local chest = "red"; 

    local route = chest;

    local reject_list = {"kalite", "coal"};
    local grind_list = {"_lump", "gravel", "gold_ingot"};
    local melt_list = {"_dust", "default:steel_ingot", "oil_extract", "paraffin", "desert_cobble", "mossycobble", "default:sand"};

    if is_in_list(event.itemstring, reject_list) then
        -- yellow port is connected to teleporter
        -- send items to the chest
    elseif is_in_list(event.itemstring, melt_list) then
        route = furnace;
    elseif is_in_list(event.itemstring, grind_list) then
        route =  grinder;
    end;
    return route;

end;

local function main()
    if event.type == "item" then 
        local dest = sort_items2()
        local message = {itemstring=event.itemstring, destination=dest}
        digiline_send("luatube", message)
        return dest;
    end
return main()
